window.onload = init;

var formName = "eventAction";

function init()
{
	$("#leagueId").change( selectChange );
	selectChange.url = "selectRace.do";
	
	$("#submitEvent").click( submitEventClick );
	
	$("#nextEvent").click( nextEventClick );
	
	$("#leagueInfo").ajaxStart(
		function()
		{  
    		$(this).html("正在加载。。。");
    		$(this).attr("disabled" , "disabled");
    		$("#homeInfo").html("正在加载。。。。");
    		$("#homeInfo").attr("disabled" , "disabled");
    		$("#roadInfo").html("正在加载。。。。");  
    		$("#roadInfo").attr("disabled" , "disabled");
		}
	);  
}

function selectChange()
{			
	$.post( 
		selectChange.url, 
		{ raceType: this.value },
		function(data)
		{	
			$("#leagueInfo").html("");
    		$("#homeInfo").html("");
    		$("#roadInfo").html("");  
			$("#leagueInfo").removeAttr("disabled")
    		$("#homeInfo").removeAttr("disabled")
    		$("#roadInfo").removeAttr("disabled") 
			$("#home").html( data );
			$("#road").html( data );
		}
	)
}

function submitEventClick()
{	
	action = "submitEvent.do";
	$("form").attr("action",action);
	
	$("form").submit();
}

function nextEventClick()
{
	action = "nextEvent.do";
	$("form").attr("action",action);
	
	$("form").submit();
	
}